package com.nf.health.app.activity.home.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;


import com.nf.health.app.R;
import com.nf.health.app.activity.home.bean.CharacteristicBean;
import com.nf.health.app.adapter.ViewHolder;
import com.nf.health.app.utils.ImageLoaderUtils;

import java.util.List;

/**
 * 特色科室  适配器  Ian
 * Created by Administrator on 2017/4/7.
 */
public class CharacteristicDepartmentAdapter extends BaseAdapter{

    List<CharacteristicBean> newsList;
    Activity activity;
    LayoutInflater inflater = null;
    public CharacteristicDepartmentAdapter(Activity activity, List<CharacteristicBean> newsList) {
        this.activity = activity;
        this.newsList = newsList;
        inflater = LayoutInflater.from(activity);
    }
    @Override
    public int getCount() {
        return newsList == null ? 0 : newsList.size();
    }

    @Override
    public Object getItem(int position) {
        if (newsList != null && newsList.size() != 0) {
            return newsList.get(position);
        }
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        CharacteristicBean item = newsList.get(position);
        ViewHolder holder = ViewHolder.get(parent, convertView, R.layout.item_characteristic_department, position);
        holder.setText(R.id.characteristic_title, item.getName());
        ImageView characteristic_image = holder.getView(R.id.characteristic_image);
        ImageLoaderUtils.getinstance(activity).getImage(characteristic_image,item.getHimg(), R.drawable.default_image);
        return holder.getConvertView();
    }


}